Math.Round(Value[, Decimals, Bankers])
.Round() method rounds the value by the precision given in the decimals argument.
Applies To
Math
Description
Math.Round() method rounds the Value provided by the precision of the optional Decimals argument.
The Functions and Operators equivalent is ROUND(nExpression, nDecimalPlaces).
Properties and Methods
None
Available
The .Round(Value[, Decimals, Bankers]) method is available in:
- 15.03.016
- All newer builds
Type
Decimal
Syntax
Math.Round(Value[, Decimals, Bankers]);
Parameters
Parameter |
Required |
Description |
---|---|---|
Value |
Yes |
The number to be rounded. Non-numeric values will be converted to 0. |
Decimals |
No |
An integer representing the number of decimals to be returned. If this argument is not provided, DEACOM rounds to the nearest integer. Non-numeric values will be converted to 0 |
Bankers |
No |
A Logical (true/false) to use Bankers rules for rounding. If the argument is not provided, DEACOM will not use Bankers rules. If set, will round .5 to the nearest even number. 1.5 rounds to 2. 2.5 rounds to 2. If you set the Bankers logical to true, you must include a Decimals parameter. |
Example
Event.Form.MessageBox('Math.Round(10.245, 2): ' + Math.Round(10.245, 2) +
'\nMath.Round(10.245): ' + Math.Round(10.235) +
'\nMath.Round(10.245, 2, true): ' + Math.Round(10.245, 2, true) +
'\nMath.Round(10.235, 2, true): ' + Math.Round(10.235, 2, true));
/* Expected System Prompt Display:
Math.Round(10.245, 2): 10.25
Math.Round(10.245): 10
Math.Round(10.245, 2, true): 10.24
Math.Round(10.235, 2, true): 10.24
*/